package cn.zf233.xcloud.commom.enums;

import cn.zf233.xcloud.commom.Const;

/**
 * Created by zf233 on 2020/1/30
 * 文件分类
 */
public enum ClassifyENUM {

    // 1:文本类型   2:图像类型  3:视频类型  4:音乐类型  0:未知类型  -1:文件夹
    UNKNOWN("unknown", -1, "https://www.xcloud.show/static/img/xcloud_front/file_type/other.png"),
    FOLDER("folder", 0, "https://www.xcloud.show/static/img/xcloud_front/file_type/folder.png"),
    TXT("txt", 1, "https://www.xcloud.show/static/img/xcloud_front/file_type/txt.png"),
    PHOTO("photo", 2, "https://www.xcloud.show/static/img/xcloud_front/file_type/photo.png"),
    VIDEO("video", 3, "https://www.xcloud.show/static/img/xcloud_front/file_type/video.png"),
    MUSIC("music", 4, "https://www.xcloud.show/static/img/xcloud_front/file_type/music.png");

    private final String describe;
    private final Integer code;
    private final String logo;

    public static Boolean exists(Integer classify) {
        for (ClassifyENUM value : values()) {
            if (value.getCode().equals(classify)) {
                return true;
            }
        }
        return false;
    }

    public static ClassifyENUM classify(Integer classify) {
        for (ClassifyENUM classifyENUM : values()) {
            if (classifyENUM.getCode().equals(classify)) {
                return classifyENUM;
            }
        }
        return ClassifyENUM.UNKNOWN;
    }

    // 判断文件类型 1:文本类型  2:图像类型  3:视频类型  4:音乐类型  0:文件夹  -1:未知
    public static ClassifyENUM checkClassify(String type) {
        return Const.CLASSIFY_MAP.get(type);
    }

    ClassifyENUM(String describe, Integer code, String logo) {
        this.describe = describe;
        this.code = code;
        this.logo = logo;
    }

    public String getDescribe() {
        return describe;
    }

    public Integer getCode() {
        return code;
    }

    public String getLogo() {
        return logo;
    }
}